package com.example.community;

import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.alibaba.android.arouter.facade.annotation.Autowired;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;

@Route(path = "/community/fragment")
public class CommunityFragment extends Fragment {
    private View rootView;
    TextView tvTitle;
    @Autowired(name = "title")
    public String title;

    public static CommunityFragment newInstance(String s){
        CommunityFragment myFragment = new CommunityFragment();
        Bundle bundle = new Bundle();
        bundle.putString("title",s);
        myFragment.setArguments(bundle);
        return myFragment;
    }


    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        rootView = inflater.inflate(R.layout.ac_community, container, false);
        ARouter.getInstance().inject(this);
        initViews();
        return rootView;
    }

    private void initViews() {
        tvTitle = rootView.findViewById(R.id.tv_title);
        if(!TextUtils.isEmpty(title)){
            tvTitle.setText(title);
            Log.d("title+----------------",title);
        }
    }

    public void setTitle(String titles) {
        this.title = titles;
    }
}
